package com.sk.sourcecircle.entity;

import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.hyphenate.chat.EMMessage;
import com.sk.sourcecircle.app.MyApplication;
import com.sk.sourcecircle.utils.MyUtils;

/**
 * Created by sk on 2018/1/5.
 */

public class MyEMMessage implements MultiItemEntity {

    private EMMessage emMessage;

    public EMMessage getEmMessage() {
        return emMessage;
    }

    public void setEmMessage(EMMessage emMessage) {
        this.emMessage = emMessage;
    }

    @Override
    public int getItemType() {
        int i = 0;
        if (!emMessage.getFrom().equals(MyUtils.getUser(MyApplication.getAppContext()).getHx_login())) {

            switch (emMessage.getType()) {
                case TXT:
                    if(emMessage.ext().containsKey("targetUrl")){
                        i = 7;
                    }else {
                        i = 1;
                    }
                    break;
                case IMAGE:
                    i = 2;
                    break;
                case VOICE:
                    i = 3;
                    break;
                case VIDEO:
                    i = 9;
                    break;
            }

        } else {
            switch (emMessage.getType()) {
                case TXT:
                    if(emMessage.ext().containsKey("targetUrl")){
                        i = 8;
                    }else {
                        i = 4;
                    }
                    break;
                case IMAGE:
                    i = 5;
                    break;
                case VOICE:
                    i = 6;
                    break;
                case VIDEO:
                    i = 10;
                    break;
            }
        }
        return i;
    }
}
